<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Elisa3: mirf.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Elisa3
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('mirf_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">mirf.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="mirf_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    Copyright (c) 2007 Stefan Engelke &lt;mbox@stefanengelke.de&gt;</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">    Permission is hereby granted, free of charge, to any person </span>
<a name="l00005"></a>00005 <span class="comment">    obtaining a copy of this software and associated documentation </span>
<a name="l00006"></a>00006 <span class="comment">    files (the &quot;Software&quot;), to deal in the Software without </span>
<a name="l00007"></a>00007 <span class="comment">    restriction, including without limitation the rights to use, copy, </span>
<a name="l00008"></a>00008 <span class="comment">    modify, merge, publish, distribute, sublicense, and/or sell copies </span>
<a name="l00009"></a>00009 <span class="comment">    of the Software, and to permit persons to whom the Software is </span>
<a name="l00010"></a>00010 <span class="comment">    furnished to do so, subject to the following conditions:</span>
<a name="l00011"></a>00011 <span class="comment"></span>
<a name="l00012"></a>00012 <span class="comment">    The above copyright notice and this permission notice shall be </span>
<a name="l00013"></a>00013 <span class="comment">    included in all copies or substantial portions of the Software.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, </span>
<a name="l00016"></a>00016 <span class="comment">    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF </span>
<a name="l00017"></a>00017 <span class="comment">    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND </span>
<a name="l00018"></a>00018 <span class="comment">    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT </span>
<a name="l00019"></a>00019 <span class="comment">    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, </span>
<a name="l00020"></a>00020 <span class="comment">    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, </span>
<a name="l00021"></a>00021 <span class="comment">    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER </span>
<a name="l00022"></a>00022 <span class="comment">    DEALINGS IN THE SOFTWARE.</span>
<a name="l00023"></a>00023 <span class="comment"></span>
<a name="l00024"></a>00024 <span class="comment">    $Id$</span>
<a name="l00025"></a>00025 <span class="comment">*/</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#ifndef _MIRF_H_</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define _MIRF_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;avr/io.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="variables_8h.html">variables.h</a>&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="leds_8h.html" title="Leds module.">leds.h</a>&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="sensors_8h.html" title="Sensors module.">sensors.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="utility_8h.html" title="Utility module.">utility.h</a>&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="comment">// Mirf settings</span>
<a name="l00038"></a><a class="code" href="mirf_8h.html#a1d5e9f7e602ce71df118cd388a72d0d7">00038</a> <span class="preprocessor">#define mirf_CH         40</span>
<a name="l00039"></a><a class="code" href="mirf_8h.html#ac72fefc5b09f825cedaa545dbd93b323">00039</a> <span class="preprocessor"></span><span class="preprocessor">#define mirf_PAYLOAD    16</span>
<a name="l00040"></a><a class="code" href="mirf_8h.html#af6b9651c5fe45bd6b8189e46b087b08b">00040</a> <span class="preprocessor"></span><span class="preprocessor">#define mirf_CONFIG     ( (1&lt;&lt;MASK_RX_DR) | (1&lt;&lt;EN_CRC) | (0&lt;&lt;CRCO) )</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 <span class="comment">// Pin definitions for chip select and chip enabled of the MiRF module</span>
<a name="l00043"></a><a class="code" href="mirf_8h.html#af332f65aca07c44deeda884c8f6c353c">00043</a> <span class="preprocessor">#define CE  PB4</span>
<a name="l00044"></a><a class="code" href="mirf_8h.html#a8df4f3a8a2035df063402ae5f0c1d2f8">00044</a> <span class="preprocessor"></span><span class="preprocessor">#define CSN PB0</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00046"></a>00046 <span class="comment">// Definitions for selecting and enabling MiRF module</span>
<a name="l00047"></a><a class="code" href="mirf_8h.html#ac350c778b5c7d78d7e9236217cc1d262">00047</a> <span class="preprocessor">#define mirf_CSN_hi     PORTB |=  (1&lt;&lt;CSN);</span>
<a name="l00048"></a><a class="code" href="mirf_8h.html#a13fd978ca6234fd2a131566b507be8a3">00048</a> <span class="preprocessor"></span><span class="preprocessor">#define mirf_CSN_lo     PORTB &amp;= ~(1&lt;&lt;CSN);</span>
<a name="l00049"></a><a class="code" href="mirf_8h.html#a3c5d623ca67313ea3c9accd005973452">00049</a> <span class="preprocessor"></span><span class="preprocessor">#define mirf_CE_hi      PORTB |=  (1&lt;&lt;CE);</span>
<a name="l00050"></a><a class="code" href="mirf_8h.html#a34e8aaef9e87a348c30d5207028c2f8e">00050</a> <span class="preprocessor"></span><span class="preprocessor">#define mirf_CE_lo      PORTB &amp;= ~(1&lt;&lt;CE);</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span>
<a name="l00052"></a>00052 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00054"></a>00054 <span class="preprocessor">#endif</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>
<a name="l00056"></a>00056 <span class="comment">// Public standard functions</span>
<a name="l00057"></a>00057 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a97564906ec706b6cd5bf1ef98e463388">mirf_init</a>();
<a name="l00058"></a>00058 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#aa6ad63edd063386a12847814d633afd4">mirf_config</a>();
<a name="l00059"></a>00059 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#aa02825055cbdbe5f403cb1bf0bbf9609">mirf_send</a>(uint8_t * value, uint8_t len);
<a name="l00060"></a>00060 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a86c04e7d5db441a8517fcef90904f2cd">mirf_set_RADDR</a>(uint8_t * adr);
<a name="l00061"></a>00061 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a23432db3b29568325b53d4932b8e5732">mirf_set_TADDR</a>(uint8_t * adr);
<a name="l00062"></a>00062 uint8_t <a class="code" href="mirf_8c.html#a13853a5c6d8ce91eafe92a76abc2b287">mirf_data_ready</a>();
<a name="l00063"></a>00063 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a44dfee6f04ab5eb4e267792297969de5">mirf_get_data</a>(uint8_t * data);
<a name="l00064"></a>00064 uint8_t <a class="code" href="mirf_8c.html#abffdd6a38e84ae4d35372f5b32e752ab">rx_fifo_is_empty</a>();
<a name="l00065"></a>00065 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#aa080fd5703fd298c641f684d8d806392">flush_rx_fifo</a>();
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a97e38a1b97f3ccd23fae567bc0cb99aa">writeAckPayload</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *data, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> size);
<a name="l00068"></a>00068 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#ae0a005d5875fc1869bbe028ab900d12f">flushTxFifo</a>();
<a name="l00069"></a>00069 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a8cfe88fad1863193840e1ef18336002c">handleRFCommands</a>();
<a name="l00070"></a>00070 uint8_t <a class="code" href="mirf_8c.html#a0ec5584f9418f0ebab4a4819e45fc350">readPayloadWidthFromTopFifo</a>();
<a name="l00071"></a>00071 uint8_t <a class="code" href="mirf_8c.html#a10acc162380a28be92ce3646c66ac12a">readPayloadWidthFromPipe0</a>();
<a name="l00072"></a>00072 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#ad6cc6fe67896c7b1ff26b46cad027830">rfEnableDebugMode</a>();
<a name="l00073"></a>00073 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a29528c378c2d7d5bfa913f0f627067fe">rfDisableDebugMode</a>();
<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a0500c9d04e87b0abe1f755a5c6fce8b5">rfDebugSendData</a>();
<a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a99e8fb5f1f93e2038f5956fe52a6d1dc">rfDebugNextPacket</a>();
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <span class="comment">// Public extended functions</span>
<a name="l00078"></a>00078 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a5d5e84dcab565368222cea7bc0011393">mirf_config_register</a>(uint8_t reg, uint8_t value);
<a name="l00079"></a>00079 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a2ec1cb46658dbf6175d5f3578518275d">mirf_read_register</a>(uint8_t reg, uint8_t * value, uint8_t len);
<a name="l00080"></a>00080 <span class="keywordtype">void</span> <a class="code" href="mirf_8c.html#a2e57e77443c90138e05be4139822e6e9">mirf_write_register</a>(uint8_t reg, uint8_t * value, uint8_t len);
<a name="l00081"></a>00081 
<a name="l00082"></a>00082 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>} <span class="comment">// extern &quot;C&quot;</span>
<a name="l00084"></a>00084 <span class="preprocessor">#endif</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>
<a name="l00086"></a>00086 <span class="preprocessor">#endif </span><span class="comment">/* _MIRF_H_ */</span>
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="mirf_8h.html">mirf.h</a>      </li>

    <li class="footer">Generated on Thu Dec 4 2014 08:30:45 for Elisa3 by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
